<script setup lang="ts">
import CommonListHeader from '@components/Common/CommonListHeader.vue';
import CommonAlbum from '@components/Common/CommonAlbum.vue'
import { ref, onBeforeMount } from 'vue';
import { MusicList } from '@/type'
import { useRouter } from 'vue-router';
import { getIndexCD } from '@utils/api';
const router = useRouter();
let musicList = ref<MusicList[]>();
onBeforeMount(() => {
    getIndexCD().then(res => {
        if (res.data.code == 1) {
            musicList.value = res.data.data
            console.log(1);

        }
    })
})


const routeToMoreMusicList = () => {
    router.push("/moreMusicList");
}
</script>
<template>
    <CommonListHeader :more="routeToMoreMusicList" type="cd" />
    <div class="list">
        <div class="music" v-for="cd of musicList">
            <CommonAlbum :cd-id="(cd.id as string)" :width="100" :height="100" :src="(cd.image as string)"
                :title="(cd.title as string)" />
        </div>
    </div>
</template>
<style lang="css" scoped>
.list {
    display: grid;
    justify-content: space-between;
    grid-template-columns: repeat(5, auto);
    padding: 0 15px;
    padding-top: 0px;
    padding-top: 10px;
    width: 100%;
}



.music .title {
    text-decoration: none;
    font-size: 14px;
    margin-top: 5px;
    width: var(--music-list-img-size);
    height: var(--content-text-height);
    cursor: pointer;
    color: black;
}

.music a:hover {
    text-decoration: underline;
}

.music img {
    width: var(--music-list-img-size);
    height: var(--music-list-img-size);
    cursor: pointer;
}
</style>